/*
 *说明 用户信息表 首页脚本
 *
 *@author liuxun 2012-03-13
*/

var opeForm;
var grid;

$(function(){
	opeForm = $('#opeForm');

	grid=$('#listTable').datagrid({
		title: '资源组  （请双击选定记录行）',
		frozenColumns:[[
            {title:'选择',field:'ck',checkbox:true}
		]],
		columns:[[

            {title:'所属机构',field:'org_name',align:'center',width:100},

            {title:'统一登录名',field:'login_name',align:'center',width:80},

            {title:'用户名',field:'usr_name',align:'center',width:80},

            {title:'用户类型',field:'usr_type_decode',align:'center',width:80},

            {title:'负责人',field:'is_leader',align:'center',width:40, 
            	formatter:function(value,rec){
            		return value ==  '1' ? '<font color="green"> √ </font>' : '<font color="red"> × </font>';
  			    }
             },

            {title:'操作员',field:'is_operator',align:'center',width:40, 
            	formatter:function(value,rec){
            		return value ==  '1' ? '<font color="green"> √ </font>' : '<font color="red"> × </font>';
 			    }
            },

            {title:'用户状态',field:'usr_status_decode',align:'center',width:40}
        ]],
		pagination:true,
		singleSelect: true,
		onDblClickRow: function(rowIndex, rowData) {
	    	window.returnValue = rowData;
	    	window.close();
	    }
	});

	queryOperation();

	$('#queryBtn').click(queryOperation);
	$('#clearBtn').click(clearOperation);
});

//翻页时自动调用此函数
function onLoadPrev(msg){
	var queryParams=grid.datagrid('options').queryParams;
	queryParams['firstQuery']=false;
}

//查询操作
function queryOperation(){
	var params = opeForm.serializeObject();
	grid.datagrid("options").pageNumber = 1;
	grid.datagrid({
		url: 'A_USR!queryList.do',
		queryParams: jQuery.extend({}, params, {'firstQuery': true})
	});
}

//清空操作（重置）
function clearOperation() {
	opeForm.resetForm();
}

//选择机构
function select_a_org() {
	var action = "A_ORG!showTree.do";
	var row = showModalWin(action);
	
	if (row) {
		$('#org_id').val(row.attributes.org_id);
		$('#org_name').val(row.attributes.org_name);
	}
}



//操作成功后刷新列表
function afterOK(){
	queryOperation();
}